﻿using System.Collections.Generic;
using Newtonsoft.Json;

namespace T.FAS.Runtime.Metadata.Entity.MF
{
    public class DataQueryNode : NodeBase
    {
        [JsonProperty("data")]
        public new DataQueryNodeData Data { get; set; }
        [JsonIgnore]
        public override string RefMetaDataID
        {
            get
            {
                return Data.DataQueryID;
            }
        }
        [JsonIgnore]
        public override string RefMetaDataType
        {
            get
            {
                return "dataquery";
            }
        }
    }

    public class DataQueryNodeData
    {
        [JsonProperty("label")]
        public string Label { get; set; }

        [JsonProperty("description")]
        public string Description { get; set; }

        [JsonProperty("dataQueryId")]
        public string DataQueryID { get; set; }
        [JsonProperty("dataQueryName")]
        public string DataQueryName { get; set; }
        [JsonProperty("dataQueryCode")]
        public string DataQueryCode { get; set; }

        [JsonProperty("parameterValues")]
        public List<DatqQueryParameterNode> ParameterValues { get; set; }

        [JsonProperty("outputFields")]
        public List<UserVariable> OutputVariables { get; set; }
        [JsonProperty("error_strategy")]
        public string ErrorStrategy { get; set; }

        [JsonProperty("default_value")]
        public List<UserVariable> DefaultValues { get; set; }
    }

    public class DatqQueryParameterNode
    {
        [JsonProperty("ID")]
        public string ID { get; set; }
        [JsonProperty("DataQueryID")]
        public string DataQueryID { get; set; }
        [JsonProperty("Code")]
        public string Code { get; set; }

        [JsonProperty("Name")]
        public string Name { get; set; }
        [JsonProperty("IsExpr")]
        public bool IsExpr { get; set; }
        [JsonProperty("IsInputParam")]
        public bool IsInputParam { get; set; }
        [JsonProperty("IsDefault")]
        public bool IsDefault { get; set; }
        [JsonProperty("DefaultValue")]
        public string DefaultValue { get; set; }
        [JsonProperty("ParamValue")]
        public object ParamValue { get; set; }

        [JsonProperty("Sort")]
        public int Sort { get; set; }
        [JsonProperty("ParamType")]
        public string ParamType { get; set; }
        [JsonProperty("ExpressJson")]
        public string ExpressJson { get; set; }

        [JsonProperty("IsAllowNull")]
        public bool IsAllowNull { get; set; }
        [JsonProperty("assignment")]
        public AssignmentNode Assignment { get; set; }

    }
    public class AssignmentNode
    {
        [JsonProperty("valueType")]
        public string ValueType { get; set; }

        [JsonProperty("constantValue",NullValueHandling = NullValueHandling.Ignore)]
        public string ConstantValue { get; set; }

        [JsonProperty("variableId")]
        public string VariableID { get; set; }

        [JsonProperty("variableNodeId")]
        public string VariableNodeID { get; set; }

        [JsonProperty("variableValue")]
        public string VariableValue { get; set; }

        [JsonProperty("variableValueId")]
        public string VariableValueID { get; set; }
    }
    public class DQOutputField
    {
        [JsonProperty("variableId")]
        public string VariableId { get; set; }
        [JsonProperty("variable")]
        public string Variable { get; set; }

        [JsonProperty("record_category")]
        public string RecordCategory { get; set; }

        [JsonProperty("type")]
        public string Type { get; set; }
    }
}
